package org.example.chapter3.service.iml;

import lombok.extern.slf4j.Slf4j;
import org.example.chapter3.dao.StudentDao;
import org.example.chapter3.entity.Student;
import org.example.chapter3.service.SLoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Slf4j
@Service
public class SLoginServiceIml implements SLoginService {
    @Autowired
    StudentDao studentDao;
    @Override
    public boolean login(String sname, String password) {
        Student student =studentDao.getStudentByName(sname);
        if (student == null){
            log.info("用户名或密码错误！");
            return false;
        }else if(student.getPassword().equals(password)){
            log.info("登录成功！");
            return true;
        }
        log.info("登录失败!");
        return false;
    }
}
